package com.nefu.huiyi.mapper;

import com.nefu.huiyi.entity.StatsEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface StatsMapper {

    @Select("SELECT COUNT(*) as physicians FROM doctor")
    int countPhysicians();

    @Select("SELECT COUNT(*) as drugsSold FROM material")
    int countDrugsSold();

    @Select("SELECT COUNT(*) as partnerCompanies FROM medical_companies")
    int countPartnerCompanies();

    @Select("SELECT COUNT(*) as salesLocations FROM doctor")
    int countSalesLocations();

    default StatsEntity getStats() {
        StatsEntity stats = new StatsEntity();
        stats.setPhysicians(this.countPhysicians());
        stats.setDrugsSold(this.countDrugsSold());
        stats.setPartnerCompanies(this.countPartnerCompanies());
        stats.setSalesLocations(this.countSalesLocations());
        return stats;
    }
}